package cate.game.chat;

import cate.game.role.Role;
import cate.game.role.show.bubble.BubbleBoxVO;
import cate.game.role.show.frame.HeadFrameVO;
import cate.game.role.show.icon.HeadIconVO;
import cate.game.role.show.title.TitleVO;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass(value = "聊天信息发送者的简单信息")
public class ChatSenderInfo {

    @NoteField(value = "唯一ID")
    public String id;

    @NoteField(value = "名字")
    public String name;

    @NoteField(value = "游戏服务器编号")
    public int srvId;

    @NoteField(value = "游戏服务器序号")
    public int srvIndex;

    @NoteField(value = "等级")
    public int level;

    @NoteField(value = "性别")
    public byte sex;

    @NoteField(value = "头像")
    public HeadIconVO headIcon;

    @NoteField(value = "头像框")
    public HeadFrameVO headFrame;

    @NoteField(value = "气泡框")
    public BubbleBoxVO bubbleBox;

    @NoteField(value = "称号",detail = "如果为null说明是隐藏了")
    public TitleVO title;

    @NoteField(value = "vip等级")
    public int vip;

    public ChatSenderInfo() {}

    public ChatSenderInfo(Role role) {
        this.id = role.getUid();
        this.name = role.getBase().name;
        this.srvId = role.getBase().srvId;
        this.level = role.getBase().level;
        this.sex = role.getBase().sex;
        this.headIcon = role.getBase().headIcon.copy();
        this.headFrame = role.getBase().headFrame.copy();
        this.bubbleBox = role.getBase().bubbleBox.copy();

        if (role.getSystem().blogConfig.chatShowTitle) {
            title = role.getBase().title;
        }
        vip = role.getBase().vip;
    }

    public static final String SYSTEM_SENDER_ID = "system";
    public static final String SYSTEM_SENDER_NAME = "系统";

    private static ChatSenderInfo systemSender;
    /** 获取系统消息发送者 */
    public static ChatSenderInfo getSystemSender() {
        if (systemSender == null) {
            systemSender = new ChatSenderInfo();
            systemSender.id = SYSTEM_SENDER_ID;
            systemSender.name = SYSTEM_SENDER_NAME;
        }
        return systemSender;
    }

    /** 获取公会消息发送者 */
    public static ChatSenderInfo getGuildSender(String guildIdHex) {
        ChatSenderInfo si = new ChatSenderInfo();
        si.id = SYSTEM_SENDER_ID;
        si.name = SYSTEM_SENDER_NAME;
        return si;
    }
}
